﻿package com.toncen.samepms.system.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.toncen.samepms.common.AbstractDatabaseAction;
import com.toncen.samepms.system.dao.SkinConfigurationDao;
import com.toncen.samepms.system.domain.SkinConfiguration;
import com.opensymphony.xwork2.ActionContext;

/**
 * 描述：个性化设置表SYSTEM_SKIN_CONFIGURATION的action文件
 * 
 * @author zq
 * 
 */
public class SkinConfigurationAction extends AbstractDatabaseAction<SkinConfiguration, SkinConfigurationDao> {
	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1338272150626L;

	public SkinConfigurationAction() throws Exception {
		super();
	}

	@Override
	public String onDoEdit() throws Exception {
		// 从cookies里拿到用户的个性化设置
		ActionContext ctx = ActionContext.getContext();
		HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
		SkinConfiguration skinCon = SkinConfiguration.getSkinConfigurationFromCookies(request);
		setDomain(skinCon);
		return SUCCESS;
	}

	@Override
	public String onDoSave() throws Exception {
		ActionContext.getContext().getSession().remove(SKIN_CONFIGURATION_SESSION_ATTRIBUTE);
		return SUCCESS;
	}

	@Override
	public void prepareOnDoEdit() throws Exception {
		// TODO Auto-generated method stub
	}

}
